﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace ViMap
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


            routes.MapRoute(
             "Get all places with few field and return json", // Route name
             "place/getPlaces", // URL with parameters
             new { controller = "Place", action = "getPlaces" } // Parameter defaults
         );

            routes.MapRoute(
              "Get all places and return json", // Route name
              "place/getAll", // URL with parameters
              new { controller = "Place", action = "getAll" } // Parameter defaults
          );

          routes.MapRoute(
              "Get places in city and return json", // Route name
              "city/getPlaces/{cityId}", // URL with parameters
              new { controller = "City", action = "getPlaceinCity", cityId = UrlParameter.Optional } // Parameter defaults
          );
            
            routes.MapRoute(
               "Search place", // Route name
               "searchPlace", // URL with parameters
               new { controller = "Search", action = "searchPlace" } // Parameter defaults
           );

            routes.MapRoute(
               "Search place by address and return json objects", // Route name
               "place/getPlacebyAddress/{address}/{cityId}", // URL with parameters
               new { controller = "Place", action = "getPlacebyAddress", address = UrlParameter.Optional, cityId = UrlParameter.Optional } // Parameter defaults
           );

            routes.MapRoute(
              "Search route", // Route name
              "searchRoute", // URL with parameters
              new { controller = "Search", action = "SearchRoute" } // Parameter defaults
          );

            routes.MapRoute(
                "Detail", // Route name
                "place/{id}", // URL with parameters
                new { controller = "Place", action = "getPlace", id = UrlParameter.Optional } // Parameter defaults
            );

          
            ////city
            routes.MapRoute(
               "get all cities and return json", // Route name
               "city/getAll", // URL with parameters
               new { controller = "City", action = "getAll"} // Parameter defaults
           );

            routes.MapRoute(
               "get city by id and return json", // Route name
               "city/{id}", // URL with parameters
               new { controller = "City", action = "getCity", id = UrlParameter.Optional } // Parameter defaults
           );

            ////default route
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes);
        }
    }
}